<template>
  <!-- 档案机构变更审核 -->
  <changeBase mold="migration-audit">
    <template v-slot:main-button>
      <mainButton
        :main-button="mainButton"
        @toMainSearch="search"
        @toMainSearchReset="reset"
      />
    </template>
    <template v-slot:search-info>
      <searchMain
        ref="searchMain"
        size="mini"
        :label-width="labelWidth"
        :model="formData"
        :rules="searchRules"
        :item-list="formItemList"
      />
      <el-divider />
    </template>
    <template v-slot:table-main>
      <common-table
        :data="infoList"
        border
        :columns-item="columns"
        :title="infoTitle"
        :loading="false"
        :display-column="displayColumn"
        @checkbox-change="selectChangeEvent"
      />
    </template>
    <template v-slot:table-member>
      <common-table
        :data="testList"
        border
        :columns-item="testColumns"
        :title="testTitle"
        @checkbox-change="selectChangeEvent"
      />
    </template>
  </changeBase>
</template>

<script>
import changeBase from "@/components/Layout/changeBase.vue"
import mainButton from "@/components/CommonButtons/MainButton.vue"
import searchMain from "@/components/CommonForm/index.vue"
import CommonTable from "@/components/CommonTable/index.vue"
import CommonForm from "@/components/CommonForm/index.vue"
// 加载模拟数据
import {
  infoList,
  testList,
  sexs,
  fileStatusType,
  changeType,
  changeState,
  addressList,
  information,
  isSignType, // 是否签约
  familyInformation, // 是否有家庭信息
  complete, // 信息是否完整
  peopleSigns, // 人口库标识
  publicSigns, // 公安标识
  dataProps,
  searchHandle
} from "@/simdata/healthData.js"
export default {
  name: "MigrationAudit",
  components: {
    changeBase,
    mainButton,
    searchMain,
    CommonTable,
    CommonForm
    // fileForm
  },
  data() {
    return {
      // 配置常用按钮
      mainButton: [
        {
          label: "变更",
          icon: "el-icon-check",
          type: "primary",
          handle: () => {
            this.addHandle()
          }
        }
      ],
      // 查询表单
      formData: {
        name: "", // 操作人
        change_type: "", // 变更类型
        createDate: "", // 建档日期 开始
        endDate: "", // 结束日期
        change_state: "" // 变更状态
      },
      // label的宽度
      labelWidth: "auto",
      // 验证
      searchRules: {},
      // 配置search label表单
      formItemList: [
        {
          type: "data",
          label: "操作日期",
          prop: "createDate",
          span: 8,
          placeholder: "请选择..."
        },
        {
          type: "data",
          label: "至",
          prop: "endDate",
          span: 8,
          placeholder: "请选择..."
        },
        {
          type: "Input",
          label: "操作人",
          prop: "name",
          span: 8,
          placeholder: ""
        },
        {
          type: "Select",
          label: "变更类型",
          prop: "change_type",
          span: 8,
          options: changeType,
          props: dataProps,
          change: row => "",
          placeholder: "请选择..."
        },

        {
          type: "Select",
          label: "变更状态",
          prop: "change_state",
          width: "120px",
          span: 8,
          options: changeState,
          props: dataProps,
          change: row => "",
          placeholder: "请选择..."
        }
      ],
      // 所有列表数据
      infoTitle: "",
      testTitle: "家庭信息列表",
      infoList: infoList,
      testList: testList,
      // 配置显示的label标签
      columns: [
        { prop: "name", label: "姓名", width: "100" },
        {
          prop: "sex",
          label: "性别",
          width: "68",
          type: "sex",
          option: sexs
        },
        { prop: "age", label: "年龄", width: "80" },
        { prop: "birthdata", label: "出生日期", width: "100" },
        { prop: "identityNumber", label: "身份证号", width: "180" },
        { prop: "phonenumber", label: "本人电话号码", width: "150" },
        { prop: "linkName", label: "联系人姓名", width: "100" },
        { prop: "linkNumber", label: "联系人电话", width: "150" },
        { prop: "nowAddress", label: "现住地址", width: "150" },
        {
          prop: "isSign",
          label: "是否签约",
          width: "80",
          type: "isSign",
          option: isSignType
        }, //
        { prop: "responsibleDoctor", label: "责任医生", width: "100" },
        {
          prop: "isHome",
          label: "家庭信息",
          width: "80",
          type: "isHome",
          option: familyInformation
        }, //
        { prop: "creatDoctor", label: "建档医生", width: "100" },
        { prop: "createDate", label: "建档日期", width: "100" },
        { prop: "myNumber", label: "个人健康档案号", width: "150" },
        { prop: "number", label: "家庭档案号", width: "150" },
        {
          prop: "isComplete",
          label: "信息是否完整",
          width: "120",
          type: "isComplete",
          option: complete
        },
        {
          prop: "isLibrary",
          label: "人口库标记",
          width: "100",
          type: "isLibrary",
          option: peopleSigns
        },
        {
          prop: "isPublic",
          label: "公安标记",
          width: "80",
          type: "isPublic",
          option: publicSigns
        }
      ],
      // 控制表格操作按钮的显示隐藏
      displayColumn: {
        operationCol: true,
        editBtn: false,
        removeBtn: true
      },
      // test配置label标签
      testColumns: [
        { prop: "name", label: "姓名", width: "100" },
        { prop: "sex", label: "性别", width: "68" },
        { prop: "age", label: "年龄", width: "80" },
        { prop: "birthdata", label: "出生日期", width: "100" },
        { prop: "identityNumber", label: "身份证号", width: "180" },
        { prop: "relation", label: "与户主关系", width: "100" }
      ]
      // Main分页
      // mainPage: {
      //   currentPage: 1,
      //   pageSize: 10,
      //   totalResult: 100
      // },
    }
  },
  mounted() {},
  methods: {
    // 点击新增按钮
    addHandle() {
      console.log("点击新增了")
    },
    // 切换常用地址
    handleChange() {
      console.log("点击了")
    },
    // 点击搜索按钮
    search(formName) {
      this.$refs.searchMain.$refs[formName].validate(valid => {
        if (valid) {
          console.log(this.formData)

          // 调用接口
          this.callbackComponent()
        } else {
          console.log("error submit!!")
          return false
        }
      })
    },
    // 点击重置按钮
    reset(formName) {
      this.$refs.searchMain.$refs[formName].resetFields()
      // console.log(this.formData)
    },
    // 点击搜索后，请求后台接口了
    callbackComponent() {
      console.log("调接口")
    },
    // 家庭基本信息复选框选中
    selectChangeEvent({ checked, records }) {
      console.log(checked)
      console.log(records)
    },

    // 接收点击复选框选中的数据
    receiveHandle(data) {
      console.log(data)
      if (data.length > 0) {
        this.formData = data[0]
      } else {
        this.formData = {}
      }
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .table-container {
  margin-right: 0 !important;
}
/deep/ .right-container {
  margin-right: 0 !important;
}
</style>
